<?php

namespace Biz\Requests\Site;

use Illuminate\Validation\Rule;
use Biz\Constants\Pay\PayConstants;
use Lumen\Validation\Validators\RequestValidator;

/**
 * SitePayRequest.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SitePayRequest extends RequestValidator
{
    /**
     * Get custom rules for validator errors.
     *
     * @return array
     */
    public function rules(): array
    {
        $rules = [
            'gateway'             => [
                'required',
                'string',
                'max:32',
                Rule::in(PayConstants::$Gateways),
            ],
        ];

        $gateway = $this->request->get('gateway');

        switch ($gateway) {
            case PayConstants::GATEWAY_PAY_EASE:
                $rules = array_merge($rules, [
                    'pay_ease'                                        => 'required|array',
                    'pay_ease.mid'                                    => 'required|string|max:32',
                    'pay_ease.secret_key'                             => 'required|string|max:128',
                    'pay_ease.return_url'                             => 'required|string|max:255',
                ]);
                break;
        }

        //dd($gateway);

        return $rules;
    }
}
